﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Controls;

namespace MT.ValidationRules
{
    public class OnlyNumValidationRules : ValidationRule
    {
        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            if (value == null || string.IsNullOrEmpty(value.ToString()))
                return new ValidationResult(true, "OK");

            var str = value.ToString();

            if (!new Regex(@"^[0-9]\d+").IsMatch(str))
            {
                return new ValidationResult(false, "");
            }
            return new ValidationResult(true, "OK");
        }
    }
}
